﻿using System;
using Unity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace AutoRule
{
    class CLimitRule
    {
        public int ruleid;
        public String RuleName;
        public String DevType;
        public String DevName;
        public String VarName;
        public int    uplimit;
        public int    downlimit;
        public int    varid;
        public int    issummer;

        public int occurtimes = 0;
        public double varvalue = 0.0;
    }

    class CLimitRules : Singleton<CLimitRules>
    {
        public void Parse()
        {
            List<CLimitRule> l = CDB.GetInstance().GetLimitRules();
            mutex.WaitOne();
            _list = l;
            mutex.ReleaseMutex();
        }

        public void Set(ref List<CLimitRule> l)
        {
            mutex.WaitOne();
            _list = l;
            mutex.ReleaseMutex();
        }

        public List<CLimitRule> Get()
        {
            mutex.WaitOne();
            List<CLimitRule> l = _list;
            mutex.ReleaseMutex();
            return l;
        }




        private List<CLimitRule> _list;
        Mutex mutex = new Mutex();
    }
}
